<template>
  <div>
    <el-row :gutter="20">
        <div class="wapperSon">
          <el-autocomplete
            class="inline-input"
            style="max-width:120px;font-size:12px;"
            v-model="queryConditions.orderNo"
            :fetch-suggestions="querySearch"
            placeholder="订单编号"
            @select="handleSelect"
            @input="handleInput"
          ></el-autocomplete>
          <el-input
            v-model="queryConditions.productNo"
            placeholder="产品编号"
            style="max-width:120px;font-size:12px;"
          ></el-input>
          <el-input
            v-model="queryConditions.procedureNo"
            placeholder="生产工序号"
            style="max-width:120px;font-size:12px;"
          ></el-input>
          <span>交期: </span>
          <el-date-picker
            style="max-width:240px;font-size:12px;"
            v-model="selectedDatetimeRange"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="handleDateSelectChange"
          >
          </el-date-picker>
          <span>日计划排产周期: </span>
          <el-date-picker
            style="max-width:240px;font-size:13px;"
            v-model="queryConditions.scheduleDate"
            type="datetime"
            placeholder="选择日期时间"
            @change="handleDateSelectChange"
          >
          </el-date-picker>
          <el-button-group style="float: left">
            <el-button
              type="primary"
              icon="el-icon-search"
              class="el-button--medium"
              @click="fetchData"
              >查询</el-button
            >
            <el-button type="primary" style="float:right" icon="el-icon-edit-outline" 
            @click="goDayReport()">
              日报工
            </el-button>
          </el-button-group>
        </div>
    </el-row>
    <el-row :gutter="20">
      <el-card class="box-card" shadow="never">
        <div slot="header" class="clearfix">
          <span>订单列表</span>
        </div>
          <el-row type="flex" justify="start">
            <el-table
              v-loading="listLoading"
              :data="list2"
              element-loading-text="Loading"
              border
              fit
              highlight-current-row
              @row-click="rowClick"
              @selection-change="handleSelectionChange"
            >
              >
              <el-table-column type="selection" width="55"></el-table-column>
              <el-table-column
                align="center"
                label="序号"
                width="95"
                v-if="false"
              >
                <template slot-scope="scope">
                  {{ scope.row.id }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="订单编号"
                width="95"
                style="display:none;"
                fixed
              >
                <template slot-scope="scope">
                  {{ scope.row.orderno }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="订单名称"
                width="95"
                style="display:none;"
                fixed
              >
                <template slot-scope="scope">
                  {{ scope.row.sbillname }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="合同编号"
                width="95"
                style="display:none;"
                fixed
              >
                <template slot-scope="scope">
                  {{ scope.row.scontractno }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="销售员id"
                width="95"
                style="display:none;"
                fixed
              >
                <template slot-scope="scope">
                  {{ scope.row.ssalesid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="订单日期"
                width="95"
                style="display:none;"
                fixed
              >
                <template slot-scope="scope">
                  {{ scope.row.dorderdate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="客户id"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.icustomerid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="产品系列"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sproductserial }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="季节代码"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sseasoncode }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="工序类型代码"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sprocesstypecode }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="spaytermcode"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.spaytermcode }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="ncommissionrate"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.ncommissionrate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="备注"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sremark }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="状态"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.istatus }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="版本"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.iversion }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="创建人"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.screator }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="创建日期"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.dcreatedate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="部门编号"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sdeptno }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="审核人"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sapprover }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="审核日期"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.dapproveddate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="合同备注"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.scontractremark }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="sartuser"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sartuser }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="dartreceiveddate"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.dartreceiveddate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="bartfinished"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.bartfinished }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="订单类型"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sordertype }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="生产状态"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.iproducestatus }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="工序工厂id"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.iprocessfactoryid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="参考款式代码"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.srefstyleno }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="srefcustpono"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.srefcustpono }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="参考交货日期"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.drefdeliverydate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="总量"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.itotalqty }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="代理商id"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.iagentid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="组织订单号"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sorgorderno }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="srefcustlotstyleno"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.srefcustlotstyleno }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="付款日期"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.ipaymentday }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="管理公司"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.imanagecompany }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="客户部门id"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.scustdeptid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="客户联系人"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.scustman }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="swashid"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.swashid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="单证工厂id"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.ideclfactid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="iproductfactid"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.iproductfactid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="bcomplete"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.bcomplete }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="spricetype"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.spricetype }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="ssalestype"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.ssalestype }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="sproducestatususerid"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sproducestatususerid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="完成日期"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.dcompletedate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="完成人员"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.scompleteperson }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="取消人员id"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.scancelproductuserid }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="取消产品日期"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.dcancelproductdate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="导出订单编号"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sexportsalesno }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="导入订单编号"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.simportorderno }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="生产日期"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.dproducedate }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="订单类型代码"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sordertypecode }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="生产状态人员名称"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.sproducestatususername }}
                </template>
              </el-table-column>
              <el-table-column
                align="center"
                label="客户二级组织代码"
                width="95"
                style="display:none;"
              >
                <template slot-scope="scope">
                  {{ scope.row.scustsubdept }}
                </template>
              </el-table-column>
            </el-table>
          </el-row>
          <el-row>
            <pagination
              v-show="total2 > 0"
              :total="total2"
              :page.sync="listQuery2.page"
              :limit.sync="listQuery2.limit"
              :page-sizes="listQuery2.pageSizes"
              @pagination="fetchData"
            />
          </el-row>
      </el-card>
    </el-row>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
import {
  getAll,
  getList,
  create,
  update,
  deleteBatch
} from "@/api/sale/saleOrderMst";
import moment from "moment";



export default {
  name: "saleordermstlistson",
  components: { Pagination },
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "gray",
        deleted: "danger"
      };
      return statusMap[status];
    }
  },
  data() {
    return {
      data2: [],
      list2: null,
      listLoading: true,
      total2: 0,
      listQuery2: {
        page: 1,
        limit: 6,
        pageSizes: [6, 10, 14]
      },
      currentSaleOrderMstTypeId: 0,
      dialogFormVisible: false,
      dialogStatus: "",
      textMap: {
        update: "编辑",
        create: "创建"
      },
      rules: {
        orderno: [
          {
            required: true,
            message: "orderno不能为空！",
            trigger: "change"
          }
        ],
        sbillname: [
          {
            required: true,
            message: "sbillname不能为空！",
            trigger: "change"
          }
        ],
        scontractno: [
          {
            required: true,
            message: "scontractno不能为空！",
            trigger: "change"
          }
        ],
        ssalesid: [
          {
            required: true,
            message: "ssalesid不能为空！",
            trigger: "change"
          }
        ],
        dorderdate: [
          {
            required: true,
            message: "dorderdate不能为空！",
            trigger: "change"
          }
        ],
        icustomerid: [
          {
            required: true,
            message: "icustomerid不能为空！",
            trigger: "change"
          }
        ],
        sproductserial: [
          {
            required: true,
            message: "sproductserial不能为空！",
            trigger: "change"
          }
        ],
        sseasoncode: [
          {
            required: true,
            message: "sseasoncode不能为空！",
            trigger: "change"
          }
        ],
        sprocesstypecode: [
          {
            required: true,
            message: "sprocesstypecode不能为空！",
            trigger: "change"
          }
        ],
        spaytermcode: [
          {
            required: true,
            message: "spaytermcode不能为空！",
            trigger: "change"
          }
        ],
        ncommissionrate: [
          {
            required: true,
            message: "ncommissionrate不能为空！",
            trigger: "change"
          }
        ],
        sremark: [
          {
            required: true,
            message: "sremark不能为空！",
            trigger: "change"
          }
        ],
        istatus: [
          {
            required: true,
            message: "istatus不能为空！",
            trigger: "change"
          }
        ],
        iversion: [
          {
            required: true,
            message: "iversion不能为空！",
            trigger: "change"
          }
        ],
        screator: [
          {
            required: true,
            message: "screator不能为空！",
            trigger: "change"
          }
        ],
        dcreatedate: [
          {
            required: true,
            message: "dcreatedate不能为空！",
            trigger: "change"
          }
        ],
        sdeptno: [
          {
            required: true,
            message: "sdeptno不能为空！",
            trigger: "change"
          }
        ],
        sapprover: [
          {
            required: true,
            message: "sapprover不能为空！",
            trigger: "change"
          }
        ],
        dapproveddate: [
          {
            required: true,
            message: "dapproveddate不能为空！",
            trigger: "change"
          }
        ],
        scontractremark: [
          {
            required: true,
            message: "scontractremark不能为空！",
            trigger: "change"
          }
        ],
        sartuser: [
          {
            required: true,
            message: "sartuser不能为空！",
            trigger: "change"
          }
        ],
        dartreceiveddate: [
          {
            required: true,
            message: "dartreceiveddate不能为空！",
            trigger: "change"
          }
        ],
        bartfinished: [
          {
            required: true,
            message: "bartfinished不能为空！",
            trigger: "change"
          }
        ],
        sordertype: [
          {
            required: true,
            message: "sordertype不能为空！",
            trigger: "change"
          }
        ],
        iproducestatus: [
          {
            required: true,
            message: "iproducestatus不能为空！",
            trigger: "change"
          }
        ],
        iprocessfactoryid: [
          {
            required: true,
            message: "iprocessfactoryid不能为空！",
            trigger: "change"
          }
        ],
        srefstyleno: [
          {
            required: true,
            message: "srefstyleno不能为空！",
            trigger: "change"
          }
        ],
        srefcustpono: [
          {
            required: true,
            message: "srefcustpono不能为空！",
            trigger: "change"
          }
        ],
        drefdeliverydate: [
          {
            required: true,
            message: "drefdeliverydate不能为空！",
            trigger: "change"
          }
        ],
        itotalqty: [
          {
            required: true,
            message: "itotalqty不能为空！",
            trigger: "change"
          }
        ],
        iagentid: [
          {
            required: true,
            message: "iagentid不能为空！",
            trigger: "change"
          }
        ],
        sorgorderno: [
          {
            required: true,
            message: "sorgorderno不能为空！",
            trigger: "change"
          }
        ],
        srefcustlotstyleno: [
          {
            required: true,
            message: "srefcustlotstyleno不能为空！",
            trigger: "change"
          }
        ],
        ipaymentday: [
          {
            required: true,
            message: "ipaymentday不能为空！",
            trigger: "change"
          }
        ],
        imanagecompany: [
          {
            required: true,
            message: "imanagecompany不能为空！",
            trigger: "change"
          }
        ],
        scustdeptid: [
          {
            required: true,
            message: "scustdeptid不能为空！",
            trigger: "change"
          }
        ],
        scustman: [
          {
            required: true,
            message: "scustman不能为空！",
            trigger: "change"
          }
        ],
        swashid: [
          {
            required: true,
            message: "swashid不能为空！",
            trigger: "change"
          }
        ],
        ideclfactid: [
          {
            required: true,
            message: "ideclfactid不能为空！",
            trigger: "change"
          }
        ],
        iproductfactid: [
          {
            required: true,
            message: "iproductfactid不能为空！",
            trigger: "change"
          }
        ],
        bcomplete: [
          {
            required: true,
            message: "bcomplete不能为空！",
            trigger: "change"
          }
        ],
        spricetype: [
          {
            required: true,
            message: "spricetype不能为空！",
            trigger: "change"
          }
        ],
        ssalestype: [
          {
            required: true,
            message: "ssalestype不能为空！",
            trigger: "change"
          }
        ],
        sproducestatususerid: [
          {
            required: true,
            message: "sproducestatususerid不能为空！",
            trigger: "change"
          }
        ],
        dcompletedate: [
          {
            required: true,
            message: "dcompletedate不能为空！",
            trigger: "change"
          }
        ],
        scompleteperson: [
          {
            required: true,
            message: "scompleteperson不能为空！",
            trigger: "change"
          }
        ],
        scancelproductuserid: [
          {
            required: true,
            message: "scancelproductuserid不能为空！",
            trigger: "change"
          }
        ],
        dcancelproductdate: [
          {
            required: true,
            message: "dcancelproductdate不能为空！",
            trigger: "change"
          }
        ],
        sexportsalesno: [
          {
            required: true,
            message: "sexportsalesno不能为空！",
            trigger: "change"
          }
        ],
        simportorderno: [
          {
            required: true,
            message: "simportorderno不能为空！",
            trigger: "change"
          }
        ],
        dproducedate: [
          {
            required: true,
            message: "dproducedate不能为空！",
            trigger: "change"
          }
        ],
        sordertypecode: [
          {
            required: true,
            message: "sordertypecode不能为空！",
            trigger: "change"
          }
        ],
        sproducestatususername: [
          {
            required: true,
            message: "sproducestatususername不能为空！",
            trigger: "change"
          }
        ],
        scustsubdept: [
          {
            required: true,
            message: "scustsubdept不能为空！",
            trigger: "change"
          }
        ]
      },
      temp: {
        id: undefined,
        orderno: "",
        sbillname: "",
        scontractno: "",
        ssalesid: "",
        dorderdate: "",
        icustomerid: "",
        sproductserial: "",
        sseasoncode: "",
        sprocesstypecode: "",
        spaytermcode: "",
        ncommissionrate: "",
        sremark: "",
        istatus: "",
        iversion: "",
        screator: "",
        dcreatedate: "",
        sdeptno: "",
        sapprover: "",
        dapproveddate: "",
        scontractremark: "",
        sartuser: "",
        dartreceiveddate: "",
        bartfinished: "",
        sordertype: "",
        iproducestatus: "",
        iprocessfactoryid: "",
        srefstyleno: "",
        srefcustpono: "",
        drefdeliverydate: "",
        itotalqty: "",
        iagentid: "",
        sorgorderno: "",
        srefcustlotstyleno: "",
        ipaymentday: "",
        imanagecompany: "",
        scustdeptid: "",
        scustman: "",
        swashid: "",
        ideclfactid: "",
        iproductfactid: "",
        bcomplete: "",
        spricetype: "",
        ssalestype: "",
        sproducestatususerid: "",
        dcompletedate: "",
        scompleteperson: "",
        scancelproductuserid: "",
        dcancelproductdate: "",
        sexportsalesno: "",
        simportorderno: "",
        dproducedate: "",
        sordertypecode: "",
        sproducestatususername: "",
        scustsubdept: ""
      },
      //表格變量
      lstSelected: [],
      queryConditions: {
        orderNo: "",
        productNo: "",
        procedureNo: "",
        updateStartTime: moment(new Date(1900, 5, 27, 15, 44, 11)).format(
          "YYYY-MM-DD HH:mm:ss"
        ),
        updateEndTime: moment(new Date()).format("YYYY-MM-DD HH:mm:ss"),
        scheduleDate: moment(new Date()).format("YYYY-MM-DD HH:mm:ss")
      },
      lstOrders: [],
      selectedDatetimeRange:[],
    };
  },

  watch: {},
  computed: {},
  created() {
    this.fetchData();
    this.getAllOrders();
  },
  methods: {
    handleSelectionChange(val) {
      this.lstSelected = val;
      const type = this.list.find(v => v.therbligsNo === val.therbligsNo);
      if (type != null) {
        this.currentSaleOrderMstTypeId = type.id;
      }
    },
    fetchData() {
      let params = {
        page: this.listQuery2.page,
        size: this.listQuery2.limit
      };
      params = Object.assign(params,this.queryConditions);
      return getList(params).then(response => {
        this.list2 = response.data.records;
        console.log(this.list2);
        this.total2 = response.data.total;
        this.listLoading = false;
      });
    },
    rowClick(row, column, event) {
      this.currentSaleOrderMstTypeId = row.id;
      this.fetchData();
    },
    resetTemp() {
      this.temp = {
        id: undefined,
        orderno: "",
        sbillname: "",
        scontractno: "",
        ssalesid: "",
        dorderdate: "",
        icustomerid: "",
        sproductserial: "",
        sseacode: "",
        sprocesstypecode: "",
        spaytermcode: "",
        ncommissionrate: "",
        sremark: "",
        istatus: "",
        iversion: "",
        screator: "",
        dcreatedate: "",
        sdeptno: "",
        sapprover: "",
        dapproveddate: "",
        scontractremark: "",
        sartuser: "",
        dartreceiveddate: "",
        bartfinished: "",
        sordertype: "",
        iproducestatus: "",
        iprocessfactoryid: "",
        srefstyleno: "",
        srefcustpono: "",
        drefdeliverydate: "",
        itotalqty: "",
        iagentid: "",
        sorgorderno: "",
        srefcustlotstyleno: "",
        ipaymentday: "",
        imanagecompany: "",
        scustdeptid: "",
        scustman: "",
        swashid: "",
        ideclfactid: "",
        iproductfactid: "",
        bcomplete: "",
        spricetype: "",
        ssalestype: "",
        sproducestatususerid: "",
        dcompletedate: "",
        scompleteperson: "",
        scancelproductuserid: "",
        dcancelproductdate: "",
        sexportsalesno: "",
        simportorderno: "",
        dproducedate: "",
        sordertypecode: "",
        sproducestatususername: "",
        scustsubdept: ""
      };
    },
    handleCreate() {
      this.resetTemp();
      this.dialogStatus = "create";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    handleUpdate() {
      if (this.lstSelected == null || this.lstSelected.length !== 1) {
        this.$message.error("请先选择一条订单记录");
        return;
      }
      this.temp = Object.assign({}, this.lstSelected[0]); // copy obj
      debugger;
      this.temp.therbligsTypeId = this.currentTherbligsTypeId;
      this.temp = { ...this.temp };
      this.dialogStatus = "update";
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate();
      });
    },
    ui_create() {
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          this.temp.id = 0; //自增
          create(this.temp).then(() => {
            this.list2.unshift(this.temp);
            this.dialogFormVisible = false;
            this.$notify({
              title: "Success",
              message: "添加成功！",
              type: "success",
              duration: 2000
            });
          });
        }
      });
    },
    ui_update() {
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          update(this.temp).then(() => {
            const index = this.list2.findIndex(v => v.id === this.temp.id);
            this.list2.splice(index, 1, this.temp);
            this.dialogFormVisible = false;
            this.$notify({
              title: "Success",
              message: "修改成功！",
              type: "success",
              duration: 2000
            });
          });
        }
      });
    },
    ui_delete(row, index) {
      if (this.lstSelected == null || this.lstSelected.length === 0) {
        this.$message.error("请先选择要删除的ActionTherbligs");
        return;
      }
      let ids = [];
      this.lstSelected.map(function(elm) {
        ids.push(elm.id);
      });
      deleteBatch(ids).then(() => {
        ids.forEach(elm => {
          const index = this.list2.findIndex(v => v.id === elm);
          this.list2.splice(index, 1);
        });
        this.dialogFormVisible = false;
        this.$notify({
          title: "Success",
          message: "删除成功！",
          type: "success",
          duration: 2000
        });
      });
    },
    handleMainTypeChange(val) {
      this.temp.saleOrderMstTypeId = val;
      this.temp = { ...this.temp };
    },
    handleDateSelectChange(val) {
      this.queryConditions.updateStartTime = moment(val[0]).format(
        "YYYY-MM-DD HH:mm:ss"
      );
      this.queryConditions.updateEndTime = moment(val[1]).format(
        "YYYY-MM-DD HH:mm:ss"
      );
    },
    querySearch(queryString, cb) {
      let orders = this.lstOrders;
      let results = queryString
        ? this.lstOrders.filter(this.createFilter(queryString))
        : this.lstOrders;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return p => {
        return p.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
      };
    },
    handleSelect(val) {
      this.queryConditions.orderNo = val.value;
    },
    handleInput(val) {
      this.queryConditions.orderNo = val;
    },
    getAllOrders()
    {
        getAll().then(response => {
           let result = response.data;
           if(result != null && result.length > 0)
           {
             result.map(v => {
                  this.lstOrders.push({value:v.orderno});
             })
           }
        })
    },
    goDayReport()
    {
       this.$router.push("/orderManager/dayreport");
    }
  }
};
</script>
<style scoped>
.item1 {
  margin-top: 20px;
}
.wapperSon {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.app-container
{
   padding: 0;
}
</style>
